package com.ruoyi.socket.gateway;

import com.alibaba.fastjson.JSON;
import com.ruoyi.socket.probuffer.DataInfo;
import com.ruoyi.socket.util.ByteStringUtils;
import com.ruoyi.socket.util.DeviceDataInfoUtils;
import com.ruoyi.socket.util.RedisPool;
import com.ruoyi.socket.util.anbaobr.SdkParse;
import io.netty.channel.group.ChannelGroup;
import io.netty.channel.group.DefaultChannelGroup;
import io.netty.util.concurrent.GlobalEventExecutor;

import java.util.Map;

/***
 *  @description 处理业务逻辑
 *  @author zhao
 *  @date: 2020/6/13
 *  @version: v1.0
 */
@Deprecated
public class MyCustomerHandler {
    private static ChannelGroup channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);

    private static MyCustomerHandler myCustomerHandler;
    private RedisPool redisPool;

    //    private NettyClientPool nettyClientPool;
    // 初始化保证
    private MyCustomerHandler() {
//        String host = "127.0.0.1";
//        Integer port = 8091;
//        nettyClientPool = NettyClientPool.getInstance(host,port);
        redisPool = RedisPool.getInstance();
    }


    public static synchronized MyCustomerHandler getInstance() {
        if (myCustomerHandler == null) {
            myCustomerHandler = new MyCustomerHandler();
        }
        return myCustomerHandler;
    }

    // 如上保证该类的单例


    //处理设备网关接收的数据
    public void handlerDeviceGateWay(String gateWayDate) {



    }

    //发送如上数据给business服务传递
    public void sendDeviceGateWay(String gateWayDate) {
        System.out.println("sendDeviceGateWay" + gateWayDate);

//        String result = nettyClientPool.sendMsg(gateWayDate);
//        System.out.println("receiveBusiness" + result);

    }

    // 接收业务服务的数据
    public void receiveBusiness(String businessData) {

        System.out.println("receiveBusiness" + businessData);

    }
}
